home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 October / DPPCPRO1005.ISO / Download / Web Developer / webdeveloper.xpi / chrome / webdeveloper.jar / content / webdeveloper / dialogs / outline_elements.js next >
Encoding:
JavaScript  |  2005-03-21  |  2.2 KB  |  62 lines

  1. // Cancels the outline elements
  2. function webdeveloper_cancelOutlineElements()
  3. {
  4.     window.opener.document.getElementById("webdeveloper-outline-custom-elements-menu").setAttribute("checked", false);
  5.  
  6.     window.close();
  7. }
  8.  
  9. // Initializes the outline elements dialog
  10. function webdeveloper_initializeOutlineElements()
  11. {
  12.     const preferencesService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("");
  13.  
  14.     var color   = null;
  15.     var element = null;
  16.  
  17.     // Loop through the possible custom elements
  18.     for(var i = 1; i <= 5; i++)
  19.     {
  20.         color   = "webdeveloper.custom." + i + ".color";
  21.         element = "webdeveloper.custom." + i + ".element";
  22.  
  23.         // If the color is set
  24.         if(preferencesService.prefHasUserValue(color))
  25.         {
  26.             document.getElementById(color).color = preferencesService.getComplexValue(color, Components.interfaces.nsISupportsString).data.trim();
  27.         }
  28.  
  29.         // If the element is set
  30.         if(preferencesService.prefHasUserValue(element))
  31.         {
  32.             document.getElementById(element).value = preferencesService.getComplexValue(element, Components.interfaces.nsISupportsString).data.trim();
  33.         }
  34.     }
  35. }
  36.  
  37. // Saves the list of colors and elements to outline
  38. function webdeveloper_saveOutlineElements()
  39. {
  40.     const preferencesService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("");
  41.     const string             = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
  42.  
  43.     var color   = null;
  44.     var element = null;
  45.  
  46.     // Loop through the possible custom elements
  47.     for(var i = 1; i <= 5; i++)
  48.     {
  49.         color   = "webdeveloper.custom." + i + ".color";
  50.         element = "webdeveloper.custom." + i + ".element";
  51.  
  52.         string.data = document.getElementById(color).color;
  53.  
  54.         preferencesService.setComplexValue(color, Components.interfaces.nsISupportsString, string);
  55.  
  56.         string.data = document.getElementById(element).value.trim();
  57.  
  58.         preferencesService.setComplexValue(element, Components.interfaces.nsISupportsString, string);
  59.     }
  60.  
  61.     window.arguments[0].push(true);
  62. }